export function httpUtils() {
    return {
        http: function (url, data, operation) {
            fetch(url, data).then(rs => {
                console.log(rs);
                return rs.json()
            }).then(data => {
                if (operation(data)) {
                    window.location.reload()
                }
            })
                .then(err => {
                    console.log(err);
                })
        }
    }
}

export function utils(){
    return {
        fullScreen: function () {
            if (!document.fullscreenElement && !document.mozFullScreenElement && !document.webkitFullscreenElement && !document.msFullscreenElement ) {
              if (document.documentElement.requestFullscreen) {
                document.documentElement.requestFullscreen();
              } else if (document.documentElement.mozRequestFullScreen) {
                document.documentElement.mozRequestFullScreen();
              } else if (document.documentElement.webkitRequestFullscreen) {
                document.documentElement.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
              } else if (document.documentElement.msRequestFullscreen) {
                document.documentElement.msRequestFullscreen();
              }
            } else {
              if (document.exitFullscreen) {
                document.exitFullscreen();
              } else if (document.mozCancelFullScreen) {
                document.mozCancelFullScreen();
              } else if (document.webkitExitFullscreen) {
                document.webkitExitFullscreen();
              } else if (document.msExitFullscreen) {
                document.msExitFullscreen();
              }
            }
          },
          center: function(parent, child){
            debugger
            child.style.top = ((parent.offsetHeight/ 2) - (child.offsetHeight / 2)) + "px"
            child.style.left = ((parent.offsetWidth / 2) - (child.offsetWidth / 2)) + "px"
          }
    }
}